package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * @author evan0213
 * @description
 */
@Data
@Entity
@Table(name = "SPECIAL_CONFIG_GAME")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SpecialConfigGame {
	/**
	 * 主键ID
	 */
	@Id
	private String key;
	/**
	 * 名称
	 */
	@Column(name = "name")
	private String name;
	/**
	 * 描述
	 */
	@Column(name = "details")
	private String details;
	/**
	 * 禁用;1:启用 0:禁用
	 */
	@Column(name = "status")
	private Integer status;
	/**
	 * 有效字段
	 */
	@Column(name = "valid_field")
	private Integer validField;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间 YYYY-MM-DD HH24:MI:SS
	 */
	@Column(name = "created_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间 YYYY-MM-DD HH24:MI:SS
	 */
	@Column(name = "updated_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date updatedTime;

	public static void putTimeAndUser(SpecialConfigGame specialConfigGame) {
		if (specialConfigGame.key != null) {
			specialConfigGame.setCreatedBy(CurrentUser.currUserName());
			specialConfigGame.setCreatedTime(new Date());
		}
		specialConfigGame.setUpdatedBy(CurrentUser.currUserName());
		specialConfigGame.setUpdatedTime(new Date());
	}
}
